/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package queenb.web.crm.controller;

import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.faces.model.SelectItem;
import javax.servlet.http.HttpServletRequest;
import queenb.net.entitybean.B630;
import queenb.net.entitybean.K100;
import queenb.net.entitybean.N100;
import queenb.web.controller.QueenbController;
import queenb.web.crm.inteface.CustomerInf;
import queenb.web.crm.store.CustomerStore;
import queenb.web.crm.store.K100Store;
import queenb.web.sms.store.M300Store;
import queenb.web.store.ContactStore;
import queenb.web.store.EmployeeStore;
import queenb.web.store.N350Store;
import queenb.web.supplier.store.T025Store;
import queenb.web.util.ComboboxUtil;
import queenb.web.util.ContextUtil;
import queenb.web.util.SessionProvider;
import queenb.web.util.Util;

/**
 *
 * @author ems
 */
public class CustomerExpand extends QueenbController {

    private CustomerStore customerStore;
    private EmployeeStore employeeStore;
    private ContactStore contactStore;
    private T025Store t025Store;
    private N350Store n350Store;
    private String NV115; // giới tính
    private String NV101;
    private String email;
    private String mobi;
    private String tel;
    private String notice;
    private String NV102 = "NONAME";
    private String NV103;
    private String NV127;
    private String NV107;
    private String NV106;
    private String NV952;
    private String NV954;
    private String NV955;
    private String NV957;
    private String NV960;
    private String NV961;
    private String NV962;
    private String NV968;
    private String NV965;
    private String NV966;
    private String NV969;
    private String NV958;
    private String NV967;
    private String TV026;
    private String TV027;
    private String TV028;
    private String TV029;
    private String TV030;
    private String nv123;// noi sinh
    private int NN117 = 1;
    private String nv351;
    private Date nd352;
    private Date nd352p;
    private Date nd353;
    private String nv354;
    private int nn355;
    private int PN100;
    private int PN100N;
    private int FN600 = 1;
    private int fk100 = 0;
    private String NV105 = "M";
    private String sexChangeItem;
    private String charSearch;
    private List<K100> listK100TT = new ArrayList<K100>();
    private List<N100> list = new ArrayList<N100>();
    private List<N100> listdifn100 = new ArrayList<N100>();
    private List<SelectItem> listComboK300 = new ArrayList<SelectItem>();
    private List<SelectItem> listComboK330 = new ArrayList<SelectItem>();
    private int FK300 = 1;// id nguồn thông tin
    private int FK330 = 1;// id status
    private String keysearch = "Nhập từ khóa";
    private int typesearch = 7;
    private List<SelectItem> combtype = new ArrayList<SelectItem>();
    private String idSearch;
    private String nv113;
    private String nv112;
    private String reload;
    private int FN550;
    private String KV102;
    private int KN114;
    private String KV101;
    private String KV103;
    private String KV106;
    private String KV107;
    private int pn350;
    private int pn350c;
    private int pn350p;
    private String nv354p;
    private String nv354c;
    private String nv351p;
    private String nv351c;
    private boolean nn355c = true;
    private boolean nn355p;
    private int countCMND;
    private int countContact;
    private int FK100;
    private int PN100ED;
    private String keySearch;
    private int cusexpandAction;
    private List<K100> listK100;
    private K100Store k100Store;
    private String mesage;
    private boolean flagExpand;
    private String message;
    private Date nd118;
    private int flagForm = 0;
    private int FK100E = 0;
    private int beginContructor;
    private String nv129;
    private String nv130;
    private CustomerInf customerInf;
    //sendmailsendRedirect
    //public static List<N100> lists = new ArrayList<N100>();
    private List<N100> listSelected = new ArrayList<N100>();
    //paging
    private int Offset = 0;
    private int Limit = 30;
    private int totalrow; // tong so dong
    private int totalpage; // tong so trang
    private int current; // traung hien tai
    static private int numrow = 30; // so dong tren 1 trang
    private int start; // bat dau lay tu record
    private int end; // lay tu record so
    private int startpage = 1; // page bat dau
    private int endpage = 1;   // page ket thuc
    private String pagename = "";
    private int totalcurent;
    private int typesearchcurent;
    private Date md301;
    private String mv303;//trang thai
    private String mv302;//noi dung tin nhan
    private String mv304;
    private String mv305;
    private String mv306;
    private String mv307;
    private String mv308;
    private String mv309;
    private String mv310;
    private int mn314;
    private int NI104;// than thiet haoc tiem aneng
    private String empString;//kiem tra acion redirect ve trang khi dong popupup sms
    private String KV108;
    private int choisetab;
    private int dayss;
    private List<SelectItem> lstEmpByID = new ArrayList<SelectItem>();
    private int fn850;
    private String loginEmp;
    private String userAction;
    private ComboboxUtil com;
    private int flagFN850;
    private int IDsavedouble;// chi luu cho mot lan
    private Date ND131;
    private Date KD115;
    private Date endDateSta;// ngay het thuc
    private Date dateStatus;// ngay du kien tham gia
    private int dayID;
    private int checkSMS;
    private int rowdemo;// getrow 1 ngay
    public CustomerExpand() throws ParseException {
        if (SessionProvider.getSessionMapValue("groupID") != null) {
            fn850 = Integer.parseInt(SessionProvider.getSessionMapValue("groupID").toString());
        }
        if (SessionProvider.getSessionMapValue("emp") != null) {
            loginEmp = SessionProvider.getSessionMapValue("emp").toString();
            userAction = loginEmp;
             System.out.println("--------N|o/ooo--------VAO DAY KO-------"+loginEmp);
        }else{
          
//            userAction = getLogin().getUserName();
//             userAction = loginEmp;
            System.out.println("----------------VAO DAY KO-----------"+userAction);
        }

        System.out.println("CustomerExpand--fn850--" + fn850 + "--emplogin---" + loginEmp);

        com = new ComboboxUtil();
        customerStore = new CustomerStore();
        contactStore = new ContactStore();
        t025Store = new T025Store();
        employeeStore = new EmployeeStore();
        n350Store = new N350Store();
        k100Store = new K100Store();
        searchAlpha();
        getKapiMenu().setAdmin(false);
        getKapiMenu().setMainmenu1("m18");
        HttpServletRequest httpServletRequest = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
        String ip = httpServletRequest.getRemoteAddr();
        //System.out.println("===================================================" + ip);
        //ThanhLuan Begin edit 31/10/2012 
        Object objflagForm = getRequest().getParameter("flagform");
        if (objflagForm != null) {
            flagForm = Integer.parseInt(objflagForm.toString());
            getKapiMenu().setFlagform(flagForm);
            if (SessionProvider.getSessionMapValue("IDSAVE") != null) {
                SessionProvider.removeSessionMapValue("IDSAVE");
                System.out.println("-------- sau khi remove---" + SessionProvider.getSessionMapValue("IDSAVE"));
            }
        }

        Object objChosetab = getRequest().getParameter("choisetab");
        if (objChosetab != null) {
            this.choisetab = Integer.parseInt(objChosetab.toString());
            getKapiMenu().setChoisetab(choisetab);
        }
        Object objempString = getRequest().getParameter("redirect");
        if (objempString != null) {
            this.empString = objempString.toString();
        }


        //sendmail Duy
        // Object listselect = SessionProvider.getSessionMapValue("listSelectedEx");
        Object listselect = SessionProvider.getSessionMapValue(getKapiMenu().getListSelectedEx());


        if (listselect == null) {
            //SessionProvider.setSessionMapValue("listSelectedEx", listSelected);
            SessionProvider.setSessionMapValue(getKapiMenu().getListSelectedEx(), listSelected);
            
        } else {
            try {
                listSelected = (List<N100>) listselect;
            } catch (Exception e) {
                listSelected = new ArrayList<N100>();
            }
        }
        if (listselect != null) {
        }

        Object listBean = SessionProvider.getSessionMapValue("listN100");
        if (listBean == null) {
            SessionProvider.setSessionMapValue("listN100", list);
        } else {
            try {
                list = (List<N100>) listBean;
            } catch (Exception e) {
                list = new ArrayList<N100>();
            }
        }


        Object objAction = getRequest().getParameter("action");
        if (objAction != null) {
            if (objAction.equals("edit")) {
                Object objPn100 = getRequest().getParameter("pn100");
                if (objPn100 != null) {
                    this.PN100 = Integer.parseInt(objPn100.toString());
                }
                Object objfk100 = getRequest().getParameter("fk100");
                if (objfk100 != null) {
                    this.FK100E = Integer.parseInt(objfk100.toString());
                }

                if (this.PN100 > 0) {
                    getDetailFrominExpand(PN100);
                }
            } else if (objAction.equals("reloadfordays")) {
                Object objDayss = getRequest().getParameter("dayss");
                if (objDayss != null) {
                    dayss = Integer.parseInt(objDayss.toString());
                }
                Object objflagFN850 = getRequest().getParameter("flagFN850");
                if (objflagFN850 != null) {
                    flagFN850 = Integer.parseInt(objflagFN850.toString());
                }
            } else if (objAction.equals("reloadfordays1")) {
                Object objDayss = getRequest().getParameter("dayID");
                if (objDayss != null) {
                    dayID = Integer.parseInt(objDayss.toString());
                }
                Object objnd131 = getRequest().getParameter("startDTD");
                if (objnd131 != "") {
                    setDateStatus(Util.parseDate(objnd131.toString(), "dd/MM/yyyy"));
                }
                Object objnd1311 = getRequest().getParameter("endDTD");
                if (objnd1311 != "") {
                    setEndDateSta(Util.parseDate(objnd1311.toString(), "dd/MM/yyyy"));
                }

                System.out.println("---------------NGAY THANG LOAD---------------------------" + dateStatus + endDateSta);
//                Object objflagFN850 = getRequest().getParameter("flagFN850");
//                if (objflagFN850 != null) {
//                    flagFN850 = Integer.parseInt(objflagFN850.toString());
//                }
            } else if (objAction.equals("updateFK100TN100")) {
                Object objpn100 = getRequest().getParameter("pn100");
                Object objfk100 = getRequest().getParameter("fk100");
                Object objkv103 = getRequest().getParameter("kv103");
                CustomerStore store = new CustomerStore();
                System.out.println("----" + objpn100 + "--" + objfk100 + "---" + objkv103);
                if (objpn100 != null && objfk100 != null) {
                    store.updateFK100OneColumn(Integer.parseInt(objpn100.toString()), Integer.parseInt(objfk100.toString()), getLogin().getUserName());
                    //store.updateColumnINT(null, "N100", "FK100", Integer.parseInt(objfk100.toString()), "PN100", Integer.parseInt(objpn100.toString()), getLogin().getUserName());
                    //  store.updateColumnINT(null, "N100R", "FK100", Integer.parseInt(objfk100.toString()), "PN100", Integer.parseInt(objpn100.toString()), getLogin().getUserName());
                    store.updateColumnINT(null, "N100", "FN600", 3, "PN100", Integer.parseInt(objpn100.toString()), getLogin().getUserName());
                    store.updateColumnINT(null, "N100", "NN117", 0, "PN100", Integer.parseInt(objpn100.toString()), getLogin().getUserName());
                    //store.updateColumnN100(null, "N100R", "KV103", objkv103.toString(), "PN100", Integer.parseInt(objpn100.toString()), getLogin().getUserName());
                }
            } else if (objAction.equals("updatemorecompany")) {
                Object objpn100 = getRequest().getParameter("pn100");
                Object objfk100 = getRequest().getParameter("fk100");
                Object objkv103 = getRequest().getParameter("kv103");
                System.out.println("----" + objpn100 + "--" + objfk100 + "---" + objkv103);
                CustomerStore store = new CustomerStore();
                if (objpn100 != null && objfk100 != null) {
                    store.updateFK100OneColumn(Integer.parseInt(objpn100.toString()), Integer.parseInt(objfk100.toString()), getLogin().getUserName());
                    // store.updateColumnINT(null, "N100", "FK100", Integer.parseInt(objfk100.toString()), "PN100", Integer.parseInt(objpn100.toString()), getLogin().getUserName());
                    // store.updateColumnINT(null, "N100R", "FK100", Integer.parseInt(objfk100.toString()), "PN100", Integer.parseInt(objpn100.toString()), getLogin().getUserName());
                    store.updateColumnINT(null, "N100", "FN600", 3, "PN100", Integer.parseInt(objpn100.toString()), getLogin().getUserName());
                    store.updateColumnINT(null, "N100", "NN117", 1, "PN100", Integer.parseInt(objpn100.toString()), getLogin().getUserName());
                    //  store.updateColumnN100(null, "N100R", "KV103", objkv103.toString(), "PN100", Integer.parseInt(objpn100.toString()), getLogin().getUserName());
                }
                //check select
            } else if (objAction.equals("addCusp100")) {
                 if( SessionProvider.getSessionMapValue("listSelected")!=null){
                    SessionProvider.removeSessionMapValue("listSelected");
                }
                Object f = getRequest().getParameter("p100");
                Object s = getRequest().getParameter("valueC");
                if ("false".equals(s.toString())) {
                    for (int i = 0; i < listSelected.size(); i++) {
                        if (listSelected.get(i).pn100 == Integer.parseInt(f.toString())) {
                            listSelected.remove(i);
                            break;
                        }
                    }
                } else {
                    for (int i = 0; i < list.size(); i++) {
                        if (list.get(i).pn100 == Integer.parseInt(f.toString())) {
//                            if (list.get(i).getNv105() != null && list.get(i).getNv105() != "" && list.get(i).getNv105().contains("@")) {
                            listSelected.add(list.get(i));
                            break;
//                            }
                        }
                    }
                }
                List<N100>  listgetrros = (List<N100>) listSelected;
                       
                System.out.println("DANH SACH CỦA DASHBOARD----------BAONHIEU ROW-------"+listgetrros.size());
                SessionProvider.setSessionMapValue("NUMBERPER", listgetrros.size());
                SessionProvider.setSessionMapValue("listSelectedEx", listSelected);
                 SessionProvider.setSessionMapValue("listSelected", listSelected);
                SessionProvider.setSessionMapValue("listN100", list);

                //check All
            } else if (objAction.equals("addAllCusp100")) {
                if( SessionProvider.getSessionMapValue("listSelected")!=null){
                    SessionProvider.removeSessionMapValue("listSelected");
                }
                Object va = getRequest().getParameter("boool");
                if ("true".equals(va.toString())) {
                    listSelected.clear();
                    for (int i = 0; i < list.size(); i++) {
//                        if (list.get(i).getNv105() != null && list.get(i).getNv105() != "" && list.get(i).getNv105().contains("@")) {
                        listSelected.add(list.get(i));
//                        }
                    }
                } else {
                    listSelected.clear();
                }
                 List<N100>  listgetrros = (List<N100>) listSelected;
                  System.out.println("DANH SACH CỦA DASHBOARD----------BAONHIEU ROW-------"+listgetrros.size());
                SessionProvider.setSessionMapValue("NUMBERPER", listgetrros.size());
                SessionProvider.setSessionMapValue("listSelectedEx", listSelected);
                SessionProvider.setSessionMapValue("listSelected", listSelected);
                SessionProvider.setSessionMapValue("listN100", list);
            } else if (objAction.equals("clear")) {
                listSelected.clear();
                SessionProvider.setSessionMapValue("listSelectedEx", null);
            } else if (objAction.equals("sendMoreSMS")) {
                Object objMV302 = getRequest().getParameter("mv302");
                if (objMV302 != null) {
                    this.mv302 = objMV302.toString();//noi dung ti nnhan
                }
                Object objMV305 = getRequest().getParameter("mv305");
                if (objMV305 != null) {
                    this.mv305 = objMV305.toString();//muc dich
                }
                if (listselect != null) {

                    Iterator iterator = listSelected.iterator();
                    M300Store m300Store = new M300Store();
                    this.mn314 = m300Store.selectIDM300("M300", "MN314", getLogin().getModule(), 1);
                    while (iterator.hasNext()) {
                        N100 n100 = (N100) iterator.next();

                        try {
                            java.sql.Timestamp date = new java.sql.Timestamp(new Date().getTime());
                            System.out.println("---dien thoai---" + n100.getNv958());
                            if (n100.getNv958() != null) {
                                m300Store.updateM300(0, getLogin().getModule(), getLogin().getCompanyNo(), n100.getPn100(), date, this.getMv302(), this.getMv303(), n100.getNv958(), this.getMv305(), n100.getVv051(), this.getMn314(), getLogin().getUserName());
                            }
                        } catch (Exception ex) {
                        }
                    }
                }
            } else if (objAction.equals("reloadEmp")) {
                getListdifn100();
            } else if (objAction.equals("editCRM")) {
                Object objFlagExpand = getRequest().getParameter("flagexpand");
                if (objFlagExpand != null) {
                    if (objFlagExpand.equals("false")) {
                        this.flagExpand = false;
                    } else {
                        this.flagExpand = true;
                    }
                }

                Object objfn100 = getRequest().getParameter("fn100");
                if (objfn100 != null) {
                    this.PN100 = Integer.parseInt(objfn100.toString());
                }
                Object objfk100 = getRequest().getParameter("fk100");
                if (objfk100 != null) {
                    this.fk100 = Integer.parseInt(objfk100.toString());
                }

                Object objnv115 = getRequest().getParameter("nv115");
                if (objnv115 != null) {
                    this.NV115 = objnv115.toString();
                }
                Object objnv102 = getRequest().getParameter("nv102");
                if (objnv102 != null) {
                    this.NV102 = objnv102.toString();
                }
                Object objnv103 = getRequest().getParameter("nv103");
                if (objnv103 != null) {
                    this.NV103 = objnv103.toString();
                }
                Object objnv123 = getRequest().getParameter("nv123");
                if (objnv123 != null) {
                    this.nv123 = objnv123.toString();
                }
                Object objnv127 = getRequest().getParameter("nv127");
                if (objnv127 != null) {
                    this.NV127 = objnv127.toString();
                }
                Object objmobi = getRequest().getParameter("mobi");
                if (objmobi != null) {
                    this.mobi = objmobi.toString();
                }
                Object objtel = getRequest().getParameter("tel");
                if (objtel != null) {
                    this.tel = objtel.toString();
                }
                Object objemail = getRequest().getParameter("email");
                if (objemail != null) {
                    this.email = objemail.toString();
                }
                Object objnd118 = getRequest().getParameter("nd118");
                System.out.println("---date -----------" + objnd118);
                if (objnd118 != "") {
                    setNd118(Util.parseDate(objnd118.toString(), "dd/MM/yyyy"));
                }
                System.out.println("---------editCRM----------------" + nd118);
                Object objnv130 = getRequest().getParameter("nv130");
                if (objnv130 != null) {
                    this.nv130 = objnv130.toString();
                }
                Object objfk330 = getRequest().getParameter("fk330");
                if (objfk330 != null) {
                    this.FK330 = Integer.parseInt(objfk330.toString());
                }
                Object objfk300 = getRequest().getParameter("fk300");
                if (objfk300 != null) {
                    this.FK300 = Integer.parseInt(objfk300.toString());
                }
                Object nn117 = getRequest().getParameter("nn117");
                if (nn117 != null) {
                    this.NN117 = Integer.parseInt(nn117.toString());
                }
                Object objfn600 = getRequest().getParameter("fn600");
                if (objfn600 != null) {
                    this.FN600 = Integer.parseInt(objfn600.toString());
                    if (FN600 != 3) {
                        FN600 = 2;
                    }

                }

                if (PN100 > 0) {
                    flagExpand = true;
                } else {
                    flagExpand = false;
                }
                saveN100andN590();


            }



        }
        //ThanhLuan End edit 31/10/2012 
        Object objectid = getRequest().getParameter("idPn100");
        if (objectid != null) {
            this.PN100 = Util.parseInt(objectid);
            SessionProvider.setSessionMapValue("PNNNN", PN100);
            System.out.println("aloooooooooooooo" + PN100);
            getDetailFrominExpand(PN100);

        }

        Object action = getRequest().getParameter("action");
        if (action != null) {
            flagExpand = true;
        }


        //paging
        int a;
        System.out.println("D:-- listEmployee is not null ");
        Object ppage = getRequest().getParameter("p");
        if (ppage != null) {
            try {
                a = Integer.parseInt(ppage.toString());
            } catch (Exception ex) {
                a = 1;
            }
            if (a == 1) {
                setCurrent(1);
                setOffset(0);
                System.out.println("D:-- setOffset: " + 0);
            } else {
                setCurrent(a);
                setOffset((a - 1) * Limit);
                System.out.println("D:-- setOffset: " + ((a - 1) * Limit));
            }
            System.out.println("D:-- page: " + a);

        } else {
            SessionProvider.setSessionMapValue("typeSearchEx", null);
            SessionProvider.setSessionMapValue("keySearchEx", null);
            setCurrent(1);
            setOffset(0);
            System.out.println("D:-- page: 1");
        }




    }

    public void reloadNV(ActionEvent event) {
        System.out.println("444444444444444444444444444444" + keySearch);
    }

    public void reload2(ActionEvent event) {
        System.out.println("aaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + keySearch);
    }

    public void searchAlpha() {

        try {
            System.out.println("==============" + ContextUtil.getRequestParameter("idSearch") + getLogin().getCharacter());
            if (ContextUtil.getRequestParameter("idSearch") != null) {
                if (getLogin().getCharacter() == null || !ContextUtil.getRequestParameter("idSearch").toString().equals(getLogin().getCharacter())) {

                    setTypesearch(3);
                    setKeysearch(ContextUtil.getRequestParameter("idSearch").toString());
                    System.out.println("---------------------------------------" + getKeysearch());
                    SessionProvider.setSessionMapValue("submitSearch", "true");
                } else {
                    SessionProvider.setSessionMapValue("submitSearch", "false");
                }
            }
            setIdSearch(ContextUtil.getRequestParameter("idSearch"));
            if (getIdSearch() != null && getIdSearch().contains("ALL")) {
                setIdSearch(null);
                getLogin().setCharacter(getIdSearch());
            } else if (getIdSearch() == null) {
                getLogin().setCharacter(getIdSearch());

            } else {
                getLogin().setCharacter(getIdSearch());

            }

        } catch (Exception ex) {
            setIdSearch("ALL");
        }

    }

    public List<K100> getListCustomerExpand() {
        try {
            if (keySearch != null) {

                listK100 = k100Store.getListCompany_Cus(getLogin().getCompanyNo(), getLogin().getModule(), keySearch, getLogin().getUserName());
            } else {
                listK100 = k100Store.getListCompany_Cus(getLogin().getCompanyNo(), getLogin().getModule(), null, getLogin().getUserName());
            }

            return listK100;
        } catch (Exception e) {
            return null;
        }

    }

    public List<N100> getListN100Expand() {
        try {
            CustomerStore store = new CustomerStore();
            List<N100> lst = store.searchListCustomerSGT(getLogin().getModule(), 99, 0, null, 0, 1, 0, 0, getLogin().getUserName());
            int total = 0;
            if (lst != null && lst.size() > 0) {
                try {
                    total = lst.get(0).getRowss();
                } catch (Exception e) {
                    total = 0;
                }
            }
            List<N100> listN100ex = store.searchListCustomerSGT(getLogin().getModule(), 99, 0, null, 0, total, 0, 0, getLogin().getUserName());
            System.out.println("NSTTTTTTTTTTTTTTTTT expand" + listN100ex.size());
            return listN100ex;

        } catch (Exception e) {
            return null;
        }
    }

    public void getDetailFrominExpand(int id) {
        try {
            CustomerStore store = new CustomerStore();

            List<N100> listN100Id = store.getListN100ID(getLogin().getModule(), getLogin().getCompanyNo(), id, getLogin().getUserName());
            if (listN100Id != null) {
                Iterator iterator = listN100Id.iterator();
                while (iterator.hasNext()) {
                    N100 n100 = (N100) iterator.next();

                    this.NV101 = n100.getNv101();
                    this.NV102 = n100.getNv102();
                    System.out.println("D:-- " + NV101 + " / " + NV102);
                    this.NV103 = n100.getNv103();
                    this.nd118 = n100.getNd128();
                    this.email = n100.getNv105();
                    this.KV102 = n100.getKv103();
                    this.fk100 = n100.getFk100();
                    this.NV127 = n100.getNv127();
                    this.mobi = n100.getNv108();
                    this.tel = n100.getNv958();
                    this.nv130 = n100.getNv130();
                    this.ND131 = n100.getNd131();
                    this.notice = n100.getNv130();
                    this.FK330 = n100.getPk330();
                    this.FK300 = n100.getPk300();
                    this.NI104 = n100.getNi104();
                    this.NN117 = n100.getNn117();
                    this.FN600 = n100.getFn600();
                    if (n100.getNv115().equals("M")) {
                        NV115 = "Mr";
                    } else if (n100.getNv115().equals("F")) {
                        NV115 = "Ms";
                    }

                    System.out.println("D:----------- " + NV115);

                }
            }


        } catch (Exception e) {
        }
    }

    // edit K100
    public void getListK100ById(int id) {
    }

    public void saveDataFK100() {

        K100Store store = new K100Store();
        int roweffect = 0;
        if (!KV102.equals("")) {
            String kv106 = Util.UnUnicode(this.KV102);
            String kv107 = Util.UnUnicode(this.KV103);
            roweffect = store.updateK100By(0, getLogin().getModule(), 0, getLogin().getCompanyNo(), 1, "CN", this.FK300, this.FK330,
                    1, 0, KV101, "", this.getKV102(), getLogin().getUserName(), this.getKV103(), kv106, kv107, this.KV108, "", "", "", "", KN114, Util.toSQLDate(KD115), 0, 0, this.getFN550(), getLogin().getUserName());

            countContact = roweffect;
            if (roweffect > 0) {
                setMessage(getResourceString("success"));

                Object objPN100EX = getRequest().getParameter("pn100EX");
                Object objPN100CX = getRequest().getParameter("pn100CX");
                if (Integer.parseInt(objPN100EX.toString()) != 0) {
                    PN100 = Integer.parseInt(objPN100EX.toString());
                }

                if (Integer.parseInt(objPN100CX.toString()) != 0) {
                    PN100 = Integer.parseInt(objPN100CX.toString());
                }



                int rs = customerStore.updateColumnN100(null, "N100", "FK100", String.valueOf(roweffect), "PN100", PN100, getLogin().getUserName());
                //cap nhat nv cho cong ty
                int rs1 = customerStore.updateColumnN100(null, "N100", "NN117", "1", "PN100", PN100, getLogin().getUserName());
                //cap nhat loai dich vu cho khach hang
                int rs0 = customerStore.updateColumnN100(null, "N100", "FN550", String.valueOf(this.getFN550()), "PN100", PN100, getLogin().getUserName());
                int rs2 = customerStore.updateColumnN100(null, "N100R", "FK100", String.valueOf(roweffect), "PN100", PN100, getLogin().getUserName());
                ///cap nhat ten cong ty cho N100R
                int rs4 = customerStore.updateColumnN100(null, "N100R", "KV103", this.getKV102(), "PN100", PN100, getLogin().getUserName());
                int rs5 = customerStore.updateColumnN100(null, "N100", "KV103", this.getKV102(), "PN100", PN100, getLogin().getUserName());

            } else {
                setMessage(getResourceString("error"));
            }
        } else {
            setMessage(getResourceString("error"));
        }


    }

    public void searchCustomerExpand(ActionEvent event) {
    }

    public void saveCarew(ActionEvent event) {

        PN100ED = Util.parseInt(SessionProvider.getSessionMapValue("IDEM").toString());
        FK100 = Util.parseInt(SessionProvider.getSessionMapValue("IDNN").toString());

        if (PN100ED != 0 && FK100 != 0) {
            int rs = customerStore.updateColumnN100(null, "N100", "FK100", String.valueOf(FK100), "PN100", PN100ED, getLogin().getUserName());
            int rs2 = customerStore.updateColumnN100(null, "N100R", "FK100", String.valueOf(FK100), "PN100", PN100ED, getLogin().getUserName());
            ///cap nhat ten cong ty cho N100R

            // int rs4 = customerStore.updateColumnN100(null, "N100R", "KV103", this.getKV102(), "PN100", PN100ED, getLogin().getUserName());
            int rs1 = customerStore.updateColumnN100(null, "N100", "NN117", "0", "PN100", PN100ED, getLogin().getUserName());

            if (rs != 0 && rs1 != 0 && rs2 != 0) {
                setMessage(getResourceString("datasavesuccessful"));
            } else {
                setMessage("Không cập nhật thành công!");
            }
        }
    }

    public void reloadfordata() {
        try {
             String dateStart =null;
             String dateEnd =null;
            if(!Util.toSQLDate(dateStatus).toString().equals("")){
                dateStart = Util.toSQLDate(dateStatus).toString().substring(8, 10) + "/" + Util.toSQLDate(dateStatus).toString().substring(5, 7) + "/" + Util.toSQLDate(dateStatus).toString().substring(0, 4); ;
            }
            if(!Util.toSQLDate(endDateSta).toString().equals("")){
                dateEnd = Util.toSQLDate(endDateSta).toString().substring(8, 10) + "/" + Util.toSQLDate(endDateSta).toString().substring(5, 7) + "/" + Util.toSQLDate(endDateSta).toString().substring(0, 4);;
            }
            
           
           System.out.println(dateStart+"--------------DAYEEEEEEEEEEE-----------"+dateEnd);
          
            sendRedirectUrlTab("customerexpandforday.jsp?action=reloadfordays1&dayID=" + 1 + "&startDTD=" + dateStart + "&endDTD=" + dateEnd);
        } catch (Exception e) {
        }
    }

    public void saveDataCustomer(ActionEvent event) {

        CustomerStore store = new CustomerStore();
        try {
            store.NewRegistration(getLogin().getModule(), getLogin().getCompanyNo(), 0, 1, getNV101(), getNV102(), getNV103(), getNV105(), getNV106(), getNV107(), Util.UnUnicode(getNV102()), Util.UnUnicode(getNV103()), getLogin().getUserName());
        } catch (Exception e) {
            System.out.println("errorrr" + e.getMessage());
        }
    }

    public void reload() {
        userAction = getLogin().getUserName();
        SessionProvider.setSessionMapValue("submitSearch", "false");
//        System.out.println(" ----------D:   Typesearch: " + typesearch);
//        System.out.println(" ----------D:   Typesearch: " + keySearch);
        SessionProvider.setSessionMapValue("typeSearchEx", typesearch);
        SessionProvider.setSessionMapValue("keySearchEx", keySearch);
        getKapiMenu().setMd5url(getRequest().getRequestURI());
    }

    public void reload1() {
        System.out.println("---change+++++++++++++" + getKeysearch() + typesearch);

    }

    public List getSelectItems() {
        List selectItems = new ArrayList();
        selectItems.add(new SelectItem("Mr", "Mr."));
        selectItems.add(new SelectItem("Ms", "Ms."));
        return selectItems;

    }

    public void saveN100andN590() throws ParseException {

        String dateStart = ContextUtil.getRequestParameter("date");

        if (dateStart != null) {
            setNd118(Util.parseDate(dateStart, "dd/MM/yyyy"));

        } else {
            // setNd118(null);
        }

        String dateStart1 = ContextUtil.getRequestParameter("date1");

        if (dateStart1 != null) {
            setND131(Util.parseDate(dateStart1, "dd/MM/yyyy"));

        } else {
            // setNd118(null);
        }

        if (nv113 == null || nv113.isEmpty()) {
            nv113 = getLogin().getUserName();
        }
        if (nv112 == null || nv112.isEmpty()) {
            nv112 = getLogin().getUserName();
        }
        if (fk100 == 0) {
            fk100 = getLogin().getFk100();
        }
        try {

            if (flagExpand == false) {
                int count = 0;
                int count1 = 0;
                if (!NV102.equals("") && !NV103.equals("")) {
                    String nv119 = Util.UnUnicode(this.NV102);
                    String nv122 = Util.UnUnicode(this.NV103);

                    if (NV115 != null) {
                        if (NV115.equals("Ms")) {
                            sexChangeItem = "F";
                        } else {
                            sexChangeItem = "M";
                        }
                    }

                    System.out.println("------ ID SAVE 2====---" + SessionProvider.getSessionMapValue("IDSAVE") + nv123);
                    if (Util.parseInt(SessionProvider.getSessionMapValue("IDSAVE")) != 0) {
                        PN100 = customerStore.updateN100By(
                                Util.parseInt(SessionProvider.getSessionMapValue("IDSAVE")), FN600, fk100, getLogin().getCompanyNo(), this.NV102, this.NV103, NI104, 0, null, this.sexChangeItem,
                                NV115, null, null, null,
                                this.nv112, nv113, 1, "K100", null, NN117,
                                Util.toSQLDate(this.getNd118()), nv119, nv122, nv123, null, null, null, NV127, Util.UnUnicode(this.getNV127()), this.getNv130(), Util.toSQLDate(this.getND131()), getLogin().getModule(), 0, this.FK300, this.FK330, getLogin().getUserName());
                    } else {
                        PN100 = customerStore.updateN100By(
                                this.PN100, FN600, fk100, getLogin().getCompanyNo(), this.NV102, this.NV103, NI104, 0, null, this.sexChangeItem,
                                NV115, null, null, null,
                                this.nv112, nv113, 1, "K100", null, NN117,
                                Util.toSQLDate(this.getNd118()), nv119, nv122, nv123, null, null, null, NV127, Util.UnUnicode(this.getNV127()), this.getNv130(), Util.toSQLDate(this.getND131()), getLogin().getModule(), 0, this.FK300, this.FK330, getLogin().getUserName());
                    }

                    if (PN100 != 0) {
                        SessionProvider.setSessionMapValue("IDSAVE", PN100);

                        if (SessionProvider.getSessionMapValue("IDSAVE") != null) {
                            IDsavedouble = Util.parseInt(SessionProvider.getSessionMapValue("IDSAVE"));
                            System.out.println("------ Session ------" + SessionProvider.getSessionMapValue("IDSAVE"));
                        }
                    }


                }
                SessionProvider.setSessionMapValue("primary_pn100", PN100);
                if (PN100 > 0) {
                    setMessage(getResourceString("success"));

                    count1 = contactStore.updateN950By(PN100, 0, "N100", null,
                            null, null, null, null, null, 1, tel, null, notice, this.mobi,
                            null, null, null, null, null, email, null, null, null, null, 1, null, null, null, getLogin().getUserName());
                    this.NV961 = this.mobi;
                    this.NV967 = this.email;
                    this.NV958 = this.tel;
                    beginContructor = PN100;
                    System.out.println("----------aa===================================");
                } else {
                    setMessage(getResourceString("error"));
                    beginContructor = 0;
                }
            } else {
                int count = 0;
                int count1 = 0;
                if (!NV102.equals("") && !NV103.equals("")) {
                    String nv119 = Util.UnUnicode(this.NV102);
                    String nv122 = Util.UnUnicode(this.NV103);
                    System.out.println("-----update N100000000---" + this.PN100 + "," + 2 + "," + fk100 + "," + 99 + "," + this.NV102 + "," + this.NV103 + "," + 1 + "," + 0 + "," + null + "," + this.sexChangeItem + "," + null + "," + null + "," + null + "," + null + "," + this.nv112 + "," + nv113 + "," + 1 + "," + "K100" + "," + null + "," + 1 + ","
                            + Util.toSQLDate(this.getNd118()) + "," + nv119 + "," + nv122 + "," + nv123 + "," + null + "," + null + "," + null + "," + NV127 + "," + Util.UnUnicode(this.getNV127()) + "," + this.getNv130() + "," + getLogin().getModule() + "," + 0 + "," + this.FK300 + "," + this.FK330 + "," + getLogin().getUserName());
                    if (NV115.equals("Ms")) {
                        sexChangeItem = "F";
                    } else {
                        sexChangeItem = "M";
                    }
                    count = customerStore.updateN100By(this.PN100, FN600, fk100, getLogin().getCompanyNo(), this.NV102, this.NV103, NI104, 0, null, this.sexChangeItem,
                            NV115, null, null, null,
                            this.nv112, nv113, 1, "K100", null, NN117,
                            Util.toSQLDate(this.getNd118()), nv119, nv122, nv123, null, null, null, NV127, Util.UnUnicode(this.getNV127()), this.getNv130(), Util.toSQLDate(this.getND131()), getLogin().getModule(), 0, this.FK300, this.FK330, getLogin().getUserName());


                }
                if (count > 0) {
                    setMessage(getResourceString("success"));
                    beginContructor = PN100;
                } else {
                    setMessage(getResourceString("error"));
                    beginContructor = 0;
                }
                System.out.println("--------------ddddddTTTTTTTTTddddddd-----------" + PN100 + count);
                SessionProvider.setSessionMapValue("primary_pn100", PN100);
                if (PN100 > 0) {
                    System.out.println("vao ham edit1");
                    System.out.println("-----update n950------" + PN100 + "," + 1 + "," + "N100" + "," + null + ","
                            + null + "," + null + "," + null + "," + null + "," + null + "," + 1 + "tel" + tel + "," + null + "," + notice + "," + null + ","
                            + this.mobi + "," + null + "," + null + "," + null + "," + null + "," + email + "," + null + "," + null + "," + null + "," + null + "," + 1 + "," + getLogin().getUserName());
                    count1 = contactStore.updateN950By(PN100, 1, "N100", null,
                            null, null, null, null, null, 1, tel, null, notice, this.mobi,
                            null, null, null, null, null, email, null, null, null, null, 1, null, null, null, getLogin().getUserName());
                    this.NV961 = this.mobi;
                    this.NV967 = this.email;
                    this.NV958 = this.tel;
                    if (count1 > 0) {
                        setMessage(getResourceString("success"));
                        beginContructor = PN100;
                    } else {
                        setMessage(getResourceString("error"));
                        beginContructor = 0;
                    }
                } else {

                    count1 = contactStore.updateN950By(PN100, 1, "N100", null,
                            null, null, null, null, null, 1, tel, null, notice, this.mobi,
                            null, null, null, null, null, email, null, null, null, null, 1, null, null, null, getLogin().getUserName());
                    this.NV961 = this.mobi;
                    this.NV967 = this.email;
                    this.NV958 = this.tel;
                    if (count1 > 0) {
                        setMessage(getResourceString("success"));
                        beginContructor = PN100;
                    } else {
                        setMessage(getResourceString("error"));
                        beginContructor = 0;
                    }
                }

            }
        } catch (Exception ex) {
            System.out.println("errorR--" + ex.getMessage());
        }


    }

    /**
     * @return the list
     */
     public List<N100> getListgetrow() {
         try {
             CustomerStore store = new CustomerStore();
             list = store.getReport_listoftabN100(getLogin().getModule(), getLogin().getCompanyNo(), 0,Util.toSQLDate(dateStatus),Util.toSQLDate(endDateSta), Offset, 1000, 0, 0, userAction);
             setRowdemo(list.size());
              System.out.println("---------------ROW------"+rowdemo);
           //  SessionProvider
             return list;
         } catch (Exception e) {
             return null;
         }
     }
    public List<N100> getList() {
        CustomerStore store = new CustomerStore();
        try {
            if (SessionProvider.getSessionMapValue("submitSearch") != null && SessionProvider.getSessionMapValue("submitSearch").toString().equals("true")) {
                setTypesearch(3);
                setKeysearch(getLogin().getCharacter());
            }
            if (getKeysearch() != null && getKeysearch().contains("Nhập từ khóa")) {
                setKeysearch(getLogin().getCharacter());
            }
            Object o = SessionProvider.getSessionMapValue("typeSearchEx");
            if (o != null) {
                int type;
                try {
                    type = Integer.parseInt(o.toString());
                } catch (Exception e) {
                    type = 0;
                }
                setTypesearch(type);
            }
            Object o2 = SessionProvider.getSessionMapValue("keySearchEx");
            if (o2 != null) {
                setKeySearch(o2.toString());
            }

            N100 n100;
            if (getDayID() != 0) {
                   System.out.println("---------------NGAY THANG LOAD---------------------------" + Util.toSQLDate(dateStatus) + Util.toSQLDate(endDateSta));
                 list = store.getReport_listoftabN100(getLogin().getModule(), getLogin().getCompanyNo(), 0,Util.toSQLDate(dateStatus),Util.toSQLDate(endDateSta), Offset, Limit, 0, 0, userAction);
            } else {
                if (getTypesearch() == 6) {

                    list = store.searchListCustomerTour(getLogin().getModule(), 99, getKeySearch(), Offset, Limit, 0, 0, getLogin().getUserName());
                } else if (this.getDayss() == 0 && getTypesearch() == 7 || getTypesearch() == 5 || getTypesearch() == 4 || getTypesearch() == 3 || getTypesearch() == 2 || getTypesearch() == 0) {

                    System.out.println("D:- ttttttttttttttttttttttttttttttttttttttttttttttttt-------------" + getLogin().getModule() + "," + 99 + "," + getTypesearch() + "," + getKeySearch() + "," + Offset + "," + Limit + "," + 0 + "," + 0 + ",'" + userAction + "'))");
                    list = store.searchListCustomerSGT(getLogin().getModule(), 99, getTypesearch(), getKeySearch(), Offset, Limit, 0, 0, userAction);

                } else if (this.getDayss() != 0 && getTypesearch() == 7 || getTypesearch() == 5 || getTypesearch() == 4 || getTypesearch() == 3 || getTypesearch() == 2 || getTypesearch() == 0) {
                    System.out.println("-----GIA TRI KHI TIM KIEM THEO NGAY----------" + getLogin().getModule()+","+ getLogin().getCompanyNo()+","+ getDayss()+","+ Offset+","+ Limit+","+ 0+","+ 0+","+ userAction);
                    list = store.getListCustomerDLDAYS(getLogin().getModule(), getLogin().getCompanyNo(), getDayss(), Offset, Limit, 0, 0, userAction);
                }
            }     
             if (Offset == 0) {
                        if (list.size() > 0) {
                            n100 = list.get(0);
                            if (n100 != null) {
                                System.out.println("------------GET ROW CUA DASHBOARD0--------------"+n100.getRowss());
                                SessionProvider.setSessionMapValue("totalcurentEx", n100.getRowss());
                            } else {
                                SessionProvider.setSessionMapValue("totalcurentEx", 0);
                            }
                        } else {
                            SessionProvider.setSessionMapValue("totalcurentEx", 0);
                        }
                    }


            System.out.println("------GOI HAM LIST CUA DASHBPOARD----------------------" + list.size());
        } catch (Exception e) {
        }
        if (list == null) {
            list = new ArrayList<N100>();
        }

        //paging
        int t;
        Object obj = SessionProvider.getSessionMapValue("totalcurentEx");
        if (obj != null) {
            try {
                t = Integer.parseInt(obj.toString());
            } catch (Exception e) {
                t = 0;
            }
            totalcurent = t;
        } else {
            totalcurent = 0;
        }

        setTotalrow(totalcurent);
        SessionProvider.setSessionMapValue("listN100", list);
        return list;
    }

    public void reloadlist(ActionEvent ac) {
        System.out.println("ActionEvent--" + loginEmp);
        userAction = loginEmp;
        setDayss(0);
        SessionProvider.setSessionMapValue("typeSearchEx", 7);
        SessionProvider.setSessionMapValue("keySearchEx", null);
        SessionProvider.setSessionMapValue("emp", loginEmp);
        sendRedirectUrlTab("customerexpand.jsp");
    }

    public void reloadlistConvert(ActionEvent ac) {
        System.out.println("ActionEvent-------------------------------------------------------------" + loginEmp);
//        userAction = loginEmp;
//        setDayss(0);
//        SessionProvider.setSessionMapValue("typeSearchEx", 7);
//        SessionProvider.setSessionMapValue("keySearchEx", null);
        if (loginEmp != null) {
            SessionProvider.setSessionMapValue("empConvert", loginEmp);
        }

    }

    /**
     * @return the listdifn100
     */
    public List<N100> getListdifn100() {
        CustomerStore store = new CustomerStore();
        System.out.println("----list emp dif--getKeySearch-" + getKeySearch() + "," + getLogin().getCompanyNo() + "," + FK100 + "," + 1 + "," + 1000 + "," + getLogin().getUserName());

        listdifn100 = store.getListN100DifK100(getLogin().getModule(), getLogin().getCompanyNo(), 0, FK100, 1, 30, getLogin().getUserName());
        System.out.println("----list " + listdifn100.size());
        return listdifn100;
    }

    public void saveSelected1() {
        int id = 0;
        // System.out.println("---select+++++++++++++" + SessionProvider.getSessionMapValue("PKKKK"));
//        if (SessionProvider.getSessionMapValue("PKKKK") == null || SessionProvider.getSessionMapValue("PKKKK").equals("")) {
//            id = Integer.parseInt(SessionProvider.getSessionMapValue("PK100SS").toString());
//        }
//        else
//        {
//            id = Integer.parseInt(SessionProvider.getSessionMapValue("PKKKK").toString());
//        }

        Object objFK100 = getRequest().getParameter("PK100");
        Object objFN600 = getRequest().getParameter("FN600");// Phan biet khach hang thuoc cong ty voi khach viec chiu trach nhiem
        System.out.println("----objfn600----" + objFN600 + "---fk100---" + objFK100);
        if (objFK100 != null) {
            this.FK100 = Integer.parseInt(objFK100.toString());
        }
        CustomerStore store = new CustomerStore();
        for (int i = 0; i < listdifn100.size(); i++) {
            System.out.println("---selectppp+++++++++++++" + listdifn100.get(i).isSelectedp());
            try {
                if (listdifn100.get(i).isSelected()) {
                    store.updateColumnINT(null, "N100", "FK100", FK100, "PN100", listdifn100.get(i).getPn100(), getLogin().getUserName());
                    store.updateColumnINT(null, "N100", "FN600", Integer.parseInt(objFN600.toString()), "PN100", list.get(i).getPn100(), getLogin().getUserName());
                    if (listdifn100.get(i).isSelectedp()) {
                        store.updateColumnINT(null, "N100", "NN117", 0, "PN100", listdifn100.get(i).getPn100(), getLogin().getUserName());
                    } else {
                        store.updateColumnINT(null, "N100", "NN117", 1, "PN100", listdifn100.get(i).getPn100(), getLogin().getUserName());
                    }
                }


                setMesage(getResourceString("success"));
            } catch (Exception ex) {
                setMesage(getResourceString("error"));
            }

        }
    }

    /**
     * @return the cusexpandAction
     */
    public int getCusexpandAction() {
        Object idd1 = getRequest().getParameter("idEm");
        if (idd1 != null) {
            PN100ED = Util.parseInt(idd1);
            SessionProvider.setSessionMapValue("IDEM", PN100ED);
        }
        Object iddd = getRequest().getParameter("iddd");
        if (iddd != null) {
            FK100 = Util.parseInt(iddd);
            SessionProvider.setSessionMapValue("IDNN", FK100);
        }
        Object cty = getRequest().getParameter("cty");
        if (cty != null) {
            KV103 = cty.toString();
            //  SessionProvider.setSessionMapValue("IDNN", FK100);
        }
        //System.out.println("aaaaaaaaaaaaaaaaaaa" + PN100ED + "bbbbbbbbbbbbbbb" + FK100 + KV102);
        if (PN100ED != 0 && FK100 != 0) {
            // int rs = customerStore.updateColumnN100(null, "N100", "FK100", String.valueOf(FK100), "PN100", PN100ED, getLogin().getUserName());
            // int rs2 = customerStore.updateColumnN100(null, "N100R", "FK100", String.valueOf(FK100), "PN100", PN100ED, getLogin().getUserName());
            ///cap nhat ten cong ty cho N100R
            //System.out.println("SSSSSSSSSSSS" + getKV102());
            //int rs4 = customerStore.updateColumnN100(null, "N100", "KV103", this.getKV102(), "PN100", PN100ED, getLogin().getUserName());
            // int rs1 = customerStore.updateColumnN100(null, "N100", "NN117", "0", "PN100", PN100ED, getLogin().getUserName());

            // update N100
            int rs1 = customerStore.updateFK100OneColumn(PN100ED, FK100, getLogin().getUserName());
            //int rs2 = customerStore.updateColumnN100(null, "N100", "KV103", KV103, "PN100", PN100ED, getLogin().getUserName());
            // update N100R
            //  int rs3 = customerStore.updateColumnINT(null, "N100R", "FK100", FK100, "PN100", PN100ED, getLogin().getUserName());
            //int rs4 = customerStore.updateColumnN100(null, "N100R", "KV103", KV103, "PN100", PN100ED, getLogin().getUserName());
        }

        return cusexpandAction;
    }

    /*
     * public void saveN950(ActionEvent event) { try { int roweffect = 0; Object
     * pn100new = SessionProvider.getSessionMapValue("primary_pn100"); if
     * (pn100new != null) { PN100 = Integer.parseInt(pn100new.toString()); } if
     * (!NV952.equals("") && !NV958.equals("")) {
     *
     * roweffect = contactStore.updateN950By(this.PN100, 1, "N100", this.NV952,
     * null, this.NV954, this.NV955, null, this.NV957, 1, this.NV958, null,
     * this.NV960, this.NV961, this.NV962, null, null, null, null, this.NV967,
     * this.NV968, this.NV969, null, null, 1, getLogin().getUserName());
     * System.out.println("-------------------" + roweffect); countContact =
     * roweffect; if (roweffect > 0) {
     * setMessage(getResourceString("datasavesuccessful")); } else {
     * setMessage("Cập nhật không thành công!"); } }
     *
     * } catch (Exception ex) { System.out.println("errorR:---" +
     * ex.getMessage()); }
     *
     * }
     */
    /*
     * public void saveAccount(ActionEvent event) { try { Object pn100new =
     * SessionProvider.getSessionMapValue("primary_pn100"); if (pn100new !=
     * null) { PN100 = Integer.parseInt(pn100new.toString()); }
     * System.out.println("PN100-----0000000000000000000000-" + PN100); if
     * (!TV027.equals("") && !TV029.equals("")) { int count =
     * t025Store.updateT025(1, PN100, "N100", TV027, TV028, TV029, TV030, 0, 0,
     * 0, getLogin().getModule(), getLogin().getCompanyNo(),
     * getLogin().getUserName()); countContact = count; if (count > 0) {
     * setMessage(getResourceString("datasavesuccessful")); } else {
     * setMessage("Cập nhật không thành công!"); } }
     *
     * } catch (Exception ex) { System.out.println("errorR:---" +
     * ex.getMessage()); }
     *
     * }
     */
    /*
     * public void saveN350(ActionEvent event) { Object pn100new =
     * SessionProvider.getSessionMapValue("primary_pn100"); if (pn100new !=
     * null) { PN100 = Integer.parseInt(pn100new.toString()); }
     *
     * System.out.println("------------TUNG ID N350----------" + PN100 + pn350);
     * if (nn355c == true) { try { String dateStart =
     * ContextUtil.getRequestParameter("dateStart"); if (!dateStart.equals(""))
     * { setNd352(Util.parseDate(dateStart, "dd/MM/yyyy")); } else {
     * setNd352(null); }
     * System.out.println("-------------------------------------------" + nv354c
     * + nv351c + "===== " + pn350c); if (!nv351c.equals("")) { int count1 =
     * n350Store.updateN350By(pn350c, PN100, nv351c,
     * Util.toSQLDate(this.getNd352()), Util.toSQLDate(this.getNd353()), nv354c,
     * 1, 7, 99, getLogin().getUserName()); countCMND = count1; if (count1 >= 0)
     * { setMessage(getResourceString("success")); } else {
     * setMessage(getResourceString("erro")); } }
     *
     * } catch (Exception ex) { System.out.println("ERROR:---" +
     * ex.getMessage()); } }
     *
     * /// //passport if (nn355p == true) { try { String dateStart =
     * ContextUtil.getRequestParameter("dateStart1"); if (!dateStart.equals(""))
     * { setNd352p(Util.parseDate(dateStart, "dd/MM/yyyy")); } else {
     * setNd352p(null); } String dateEnd =
     * ContextUtil.getRequestParameter("dateEnd1"); try { if
     * (!dateEnd.equals("")) { setNd353(Util.parseDate(dateEnd, "dd/MM/yyyy"));
     * } else { setNd353(null); } } catch (Exception e) { }
     *
     * System.out.println("PN100-----0000000000000000000000-" + PN100 + "===== "
     * + pn350p);
     *
     * if (!nv351p.equals("")) { int count2 = n350Store.updateN350By(pn350p,
     * PN100, this.getNv351p(), Util.toSQLDate(this.getNd352p()),
     * Util.toSQLDate(this.getNd353()), this.getNv354p(), 2, 7, 99,
     * getLogin().getUserName());
     *
     * countCMND = count2; if (count2 >= 0) {
     * setMessage(getResourceString("datasavesuccessful")); } else {
     * setMessage("Cập nhật không thành công!"); } }
     *
     * } catch (Exception ex) { System.out.println("ERROR:---" +
     * ex.getMessage()); } }
     *
     * }
     */
    /**
     * @return the NV102
     */
    public String getNV102() {
        return NV102;
    }

    /**
     * @param NV102 the NV102 to set
     */
    public void setNV102(String NV102) {
        this.NV102 = NV102;
    }

    /**
     * @return the NV103
     */
    public String getNV103() {
        return NV103;
    }

    /**
     * @param NV103 the NV103 to set
     */
    public void setNV103(String NV103) {
        this.NV103 = NV103;
    }

    /**
     * @return the NV107
     */
    public String getNV107() {
        return NV107;
    }

    /**
     * @param NV107 the NV107 to set
     */
    public void setNV107(String NV107) {
        this.NV107 = NV107;
    }

    /**
     * @return the charSearch
     */
    public String getCharSearch() {
        return charSearch;
    }

    /**
     * @param charSearch the charSearch to set
     */
    public void setCharSearch(String charSearch) {
        this.charSearch = charSearch;
    }

    /**
     * @param list the list to set
     */
    public void setList(List<N100> list) {
        this.setList(list);
    }

    /**
     * @return the keysearch
     */
    public String getKeysearch() {
        return keysearch;
    }

    /**
     * @param keysearch the keysearch to set
     */
    public void setKeysearch(String keysearch) {
        this.keysearch = keysearch;
    }

    /**
     * @return the typesearch
     */
    public int getTypesearch() {
        return typesearch;
    }

    /**
     * @param typesearch the typesearch to set
     */
    public void setTypesearch(int typesearch) {
        this.typesearch = typesearch;
    }

    /**
     * @return the combtype
     */
    public List<SelectItem> getCombtype() {
        if (combtype.size() == 0) {
            combtype.add(new SelectItem(0, "Tất cả"));
            combtype.add(new SelectItem(1, "Công ty"));
            combtype.add(new SelectItem(2, "Điện thoại"));
            combtype.add(new SelectItem(3, "Họ tên"));
            combtype.add(new SelectItem(4, "CMND/Passport"));
            combtype.add(new SelectItem(5, "Email"));
        }
        return combtype;
    }

    /**
     * @param combtype the combtype to set
     */
    public void setCombtype(List<SelectItem> combtype) {
        this.setCombtype(combtype);
    }

    /**
     * @return the NV106
     */
    public String getNV106() {
        return NV106;
    }

    /**
     * @param NV106 the NV106 to set
     */
    public void setNV106(String NV106) {
        this.NV106 = NV106;
    }

    /**
     * @return the NV101
     */
    public String getNV101() {
        return NV101;
    }

    /**
     * @param NV101 the NV101 to set
     */
    public void setNV101(String NV101) {
        this.NV101 = NV101;
    }

    /**
     * @return the NV105
     */
    public String getNV105() {
        return NV105;
    }

    /**
     * @param NV105 the NV105 to set
     */
    public void setNV105(String NV105) {
        this.NV105 = NV105;
    }

    /**
     * @return the idSearch
     */
    public String getIdSearch() {
        return idSearch;
    }

    /**
     * @param idSearch the idSearch to set
     */
    public void setIdSearch(String idSearch) {
        this.idSearch = idSearch;
    }

    /**
     * @return the PN100
     */
    public int getPN100() {
        return PN100;
    }

    /**
     * @param PN100 the PN100 to set
     */
    public void setPN100(int PN100) {
        this.PN100 = PN100;
    }

    /**
     * @return the FN600
     */
    public int getFN600() {
        return FN600;
    }

    /**
     * @param FN600 the FN600 to set
     */
    public void setFN600(int FN600) {
        this.FN600 = FN600;
    }

    /**
     * @return the fk100
     */
    public int getFk100() {
        return fk100;
    }

    /**
     * @param fk100 the fk100 to set
     */
    public void setFk100(int fk100) {
        this.fk100 = fk100;
    }

    /**
     * @return the sexChangeItem
     */
    public String getSexChangeItem() {
        return sexChangeItem;
    }

    /**
     * @param sexChangeItem the sexChangeItem to set
     */
    public void setSexChangeItem(String sexChangeItem) {
        this.sexChangeItem = sexChangeItem;
    }

    /**
     * @return the NV958
     */
    public String getNV958() {
        return NV958;
    }

    /**
     * @param NV958 the NV958 to set
     */
    public void setNV958(String NV958) {
        this.NV958 = NV958;
    }

    /**
     * @return the NV967
     */
    public String getNV967() {
        return NV967;
    }

    /**
     * @param NV967 the NV967 to set
     */
    public void setNV967(String NV967) {
        this.NV967 = NV967;
    }

    /**
     * @return the NV955
     */
    public String getNV955() {
        return NV955;
    }

    /**
     * @param NV955 the NV955 to set
     */
    public void setNV955(String NV955) {
        this.NV955 = NV955;
    }

    /**
     * @return the NV957
     */
    public String getNV957() {
        return NV957;
    }

    /**
     * @param NV957 the NV957 to set
     */
    public void setNV957(String NV957) {
        this.NV957 = NV957;
    }

    /**
     * @return the NV960
     */
    public String getNV960() {
        return NV960;
    }

    /**
     * @param NV960 the NV960 to set
     */
    public void setNV960(String NV960) {
        this.NV960 = NV960;
    }

    /**
     * @return the NV961
     */
    public String getNV961() {
        return NV961;
    }

    /**
     * @param NV961 the NV961 to set
     */
    public void setNV961(String NV961) {
        this.NV961 = NV961;
    }

    /**
     * @return the NV962
     */
    public String getNV962() {
        return NV962;
    }

    /**
     * @param NV962 the NV962 to set
     */
    public void setNV962(String NV962) {
        this.NV962 = NV962;
    }

    /**
     * @return the NV968
     */
    public String getNV968() {
        return NV968;
    }

    /**
     * @param NV968 the NV968 to set
     */
    public void setNV968(String NV968) {
        this.NV968 = NV968;
    }

    /**
     * @return the NV969
     */
    public String getNV969() {
        return NV969;
    }

    /**
     * @param NV969 the NV969 to set
     */
    public void setNV969(String NV969) {
        this.NV969 = NV969;
    }

    /**
     * @return the NV952
     */
    public String getNV952() {
        return NV952;
    }

    /**
     * @param NV952 the NV952 to set
     */
    public void setNV952(String NV952) {
        this.NV952 = NV952;
    }

    /**
     * @return the NV954
     */
    public String getNV954() {
        return NV954;
    }

    /**
     * @param NV954 the NV954 to set
     */
    public void setNV954(String NV954) {
        this.NV954 = NV954;
    }

    /**
     * @return the email
     */
    public String getEmail() {
        return email;
    }

    /**
     * @param email the email to set
     */
    public void setEmail(String email) {
        this.email = email;
    }

    /**
     * @return the mobi
     */
    public String getMobi() {
        return mobi;
    }

    /**
     * @param mobi the mobi to set
     */
    public void setMobi(String mobi) {
        this.mobi = mobi;
    }

    /**
     * @return the PN100N
     */
    public int getPN100N() {
        return PN100N;
    }

    /**
     * @param PN100N the PN100N to set
     */
    public void setPN100N(int PN100N) {
        this.PN100N = PN100N;
    }

    /**
     * @return the TV026
     */
    public String getTV026() {
        return TV026;
    }

    /**
     * @param TV026 the TV026 to set
     */
    public void setTV026(String TV026) {
        this.TV026 = TV026;
    }

    /**
     * @return the TV027
     */
    public String getTV027() {
        return TV027;
    }

    /**
     * @param TV027 the TV027 to set
     */
    public void setTV027(String TV027) {
        this.TV027 = TV027;
    }

    /**
     * @return the TV028
     */
    public String getTV028() {
        return TV028;
    }

    /**
     * @param TV028 the TV028 to set
     */
    public void setTV028(String TV028) {
        this.TV028 = TV028;
    }

    /**
     * @return the TV029
     */
    public String getTV029() {
        return TV029;
    }

    /**
     * @param TV029 the TV029 to set
     */
    public void setTV029(String TV029) {
        this.TV029 = TV029;
    }

    /**
     * @return the TV030
     */
    public String getTV030() {
        return TV030;
    }

    /**
     * @param TV030 the TV030 to set
     */
    public void setTV030(String TV030) {
        this.TV030 = TV030;
    }

    /**
     * @return the nv351
     */
    public String getNv351() {
        return nv351;
    }

    /**
     * @param nv351 the nv351 to set
     */
    public void setNv351(String nv351) {
        this.nv351 = nv351;
    }

    /**
     * @return the nd352
     */
    public Date getNd352() {
        return nd352;
    }

    /**
     * @param nd352 the nd352 to set
     */
    public void setNd352(Date nd352) {
        this.nd352 = nd352;
    }

    /**
     * @return the nd353
     */
    public Date getNd353() {
        return nd353;
    }

    /**
     * @param nd353 the nd353 to set
     */
    public void setNd353(Date nd353) {
        this.nd353 = nd353;
    }

    /**
     * @return the nv354
     */
    public String getNv354() {
        return nv354;
    }

    /**
     * @param nv354 the nv354 to set
     */
    public void setNv354(String nv354) {
        this.nv354 = nv354;
    }

    /**
     * @return the nn355
     */
    public int getNn355() {
        return nn355;
    }

    /**
     * @param nn355 the nn355 to set
     */
    public void setNn355(int nn355) {
        this.nn355 = nn355;
    }

    /**
     * @return the nv113
     */
    public String getNv113() {
        if (nv113 == null || nv113.isEmpty()) {
            nv113 = getLogin().getUserName();
        }
        return nv113;
    }

    /**
     * @param nv113 the nv113 to set
     */
    public void setNv113(String nv113) {
        this.nv113 = nv113;
    }

    /**
     * @return the nv112
     */
    public String getNv112() {
        if (nv112 == null || nv112.isEmpty()) {
            nv112 = getLogin().getUserName();
        }
        return nv112;
    }

    /**
     * @param nv112 the nv112 to set
     */
    public void setNv112(String nv112) {
        this.nv112 = nv112;
    }

    /**
     * @return the nn355c
     */
    public boolean getNn355c() {
        return nn355c;
    }

    /**
     * @param nn355c the nn355c to set
     */
    public void setNn355c(boolean nn355c) {
        this.nn355c = nn355c;
    }

    /**
     * @return the nn355p
     */
    public boolean getNn355p() {
        return nn355p;
    }

    /**
     * @param nn355p the nn355p to set
     */
    public void setNn355p(boolean nn355p) {
        this.nn355p = nn355p;
    }

    /**
     * @return the reload
     */
    public String getReload() {
        return reload;
    }

    /**
     * @param reload the reload to set
     */
    public void setReload(String reload) {
        this.reload = reload;
    }

    /**
     * @return the FN550
     */
    public int getFN550() {
        return FN550;
    }

    /**
     * @param FN550 the FN550 to set
     */
    public void setFN550(int FN550) {
        this.FN550 = FN550;
    }

    /**
     * @return the KV102
     */
    public String getKV102() {
        return KV102;
    }

    /**
     * @param KV102 the KV102 to set
     */
    public void setKV102(String KV102) {
        this.KV102 = KV102;
    }

    /**
     * @return the KV103
     */
    public String getKV103() {
        return KV103;
    }

    /**
     * @param KV103 the KV103 to set
     */
    public void setKV103(String KV103) {
        this.KV103 = KV103;
    }

    /**
     * @return the nv354p
     */
    public String getNv354p() {
        return nv354p;
    }

    /**
     * @param nv354p the nv354p to set
     */
    public void setNv354p(String nv354p) {
        this.nv354p = nv354p;
    }

    /**
     * @return the nv354c
     */
    public String getNv354c() {
        return nv354c;
    }

    /**
     * @param nv354c the nv354c to set
     */
    public void setNv354c(String nv354c) {
        this.nv354c = nv354c;
    }

    /**
     * @return the nv351p
     */
    public String getNv351p() {
        return nv351p;
    }

    /**
     * @param nv351p the nv351p to set
     */
    public void setNv351p(String nv351p) {
        this.nv351p = nv351p;
    }

    /**
     * @return the nv351c
     */
    public String getNv351c() {
        return nv351c;
    }

    /**
     * @param nv351c the nv351c to set
     */
    public void setNv351c(String nv351c) {
        this.nv351c = nv351c;
    }

    /**
     * @return the countCMND
     */
    public int getCountCMND() {
        return countCMND;
    }

    /**
     * @param countCMND the countCMND to set
     */
    public void setCountCMND(int countCMND) {
        this.countCMND = countCMND;
    }

    /**
     * @return the countContact
     */
    public int getCountContact() {
        return countContact;
    }

    /**
     * @param countContact the countContact to set
     */
    public void setCountContact(int countContact) {
        this.countContact = countContact;
    }

    /**
     * @param cusexpandAction the cusexpandAction to set
     */
    public void setCusexpandAction(int cusexpandAction) {
        this.cusexpandAction = cusexpandAction;
    }

    /**
     * @return the FK100
     */
    public int getFK100() {
        return FK100;
    }

    /**
     * @param FK100 the FK100 to set
     */
    public void setFK100(int FK100) {
        this.FK100 = FK100;
    }

    /**
     * @return the PN100ED
     */
    public int getPN100ED() {
        return PN100ED;
    }

    /**
     * @param PN100ED the PN100ED to set
     */
    public void setPN100ED(int PN100ED) {
        this.PN100ED = PN100ED;
    }

    /**
     * @return the keySearch
     */
    public String getKeySearch() {
        return keySearch;
    }

    /**
     * @param keySearch the keySearch to set
     */
    public void setKeySearch(String keySearch) {
        this.keySearch = keySearch;
    }

    /**
     * @return the mesage
     */
    public String getMesage() {
        return mesage;
    }

    /**
     * @param mesage the mesage to set
     */
    public void setMesage(String mesage) {
        this.mesage = mesage;
    }

    /**
     * @return the tel
     */
    public String getTel() {
        return tel;
    }

    /**
     * @param tel the tel to set
     */
    public void setTel(String tel) {
        this.tel = tel;
    }

    /**
     * @return the notice
     */
    public String getNotice() {
        return notice;
    }

    /**
     * @param notice the notice to set
     */
    public void setNotice(String notice) {
        this.notice = notice;
    }

    /**
     * @return the KV106
     */
    public String getKV106() {
        return KV106;
    }

    /**
     * @param KV106 the KV106 to set
     */
    public void setKV106(String KV106) {
        this.KV106 = KV106;
    }

    /**
     * @return the KV107
     */
    public String getKV107() {
        return KV107;
    }

    /**
     * @param KV107 the KV107 to set
     */
    public void setKV107(String KV107) {
        this.KV107 = KV107;
    }

    /**
     * @return the flagExpand
     */
    public boolean isFlagExpand() {
        return flagExpand;
    }

    /**
     * @param flagExpand the flagExpand to set
     */
    public void setFlagExpand(boolean flagExpand) {
        this.flagExpand = flagExpand;
    }

    /**
     * @return the nd352p
     */
    public Date getNd352p() {
        return nd352p;
    }

    /**
     * @param nd352p the nd352p to set
     */
    public void setNd352p(Date nd352p) {
        this.nd352p = nd352p;
    }

    /**
     * @return the message
     */
    public String getMessage() {
        return message;
    }

    /**
     * @param message the message to set
     */
    public void setMessage(String message) {
        this.message = message;
    }

    /**
     * @return the pn350
     */
    public int getPn350() {
        return pn350;
    }

    /**
     * @param pn350 the pn350 to set
     */
    public void setPn350(int pn350) {
        this.pn350 = pn350;
    }

    /**
     * @return the pn350c
     */
    public int getPn350c() {
        return pn350c;
    }

    /**
     * @param pn350c the pn350c to set
     */
    public void setPn350c(int pn350c) {
        this.pn350c = pn350c;
    }

    /**
     * @return the pn350p
     */
    public int getPn350p() {
        return pn350p;
    }

    /**
     * @param pn350p the pn350p to set
     */
    public void setPn350p(int pn350p) {
        this.pn350p = pn350p;
    }

    /**
     * @return the NV965
     */
    public String getNV965() {
        return NV965;
    }

    /**
     * @param NV965 the NV965 to set
     */
    public void setNV965(String NV965) {
        this.NV965 = NV965;
    }

    /**
     * @return the NV966
     */
    public String getNV966() {
        return NV966;
    }

    /**
     * @param NV966 the NV966 to set
     */
    public void setNV966(String NV966) {
        this.NV966 = NV966;
    }

    /**
     * @return the nd118
     */
    public Date getNd118() {
        return nd118;
    }

    /**
     * @param nd118 the nd118 to set
     */
    public void setNd118(Date nd118) {
        this.nd118 = nd118;
    }

    /**
     * @return the NV127
     */
    public String getNV127() {
        return NV127;
    }

    /**
     * @param NV127 the NV127 to set
     */
    public void setNV127(String NV127) {
        this.NV127 = NV127;
    }

    /**
     * @return the KV101
     */
    public String getKV101() {
        return KV101;
    }

    /**
     * @param KV101 the KV101 to set
     */
    public void setKV101(String KV101) {
        this.KV101 = KV101;
    }

    /**
     * @return the KN114
     */
    public int getKN114() {
        return KN114;
    }

    /**
     * @param KN114 the KN114 to set
     */
    public void setKN114(int KN114) {
        this.KN114 = KN114;
    }

    /**
     * @return the flagForm
     */
    public int getFlagForm() {
        return flagForm;
    }

    /**
     * @param flagForm the flagForm to set
     */
    public void setFlagForm(int flagForm) {
        this.flagForm = flagForm;
    }

    /**
     * @param listdifn100 the listdifn100 to set
     */
    public void setListdifn100(List<N100> listdifn100) {
        this.listdifn100 = listdifn100;
    }

    /**
     * @return the FK100E
     */
    public int getFK100E() {
        return FK100E;
    }

    /**
     * @param FK100E the FK100E to set
     */
    public void setFK100E(int FK100E) {
        this.FK100E = FK100E;
    }

    /**
     * @return the beginContructor
     */
    public int getBeginContructor() {
        return beginContructor;
    }

    /**
     * @param beginContructor the beginContructor to set
     */
    public void setBeginContructor(int beginContructor) {
        this.beginContructor = beginContructor;
    }

    /**
     * @return the nv129
     */
    public String getNv129() {
        return nv129;
    }

    /**
     * @param nv129 the nv129 to set
     */
    public void setNv129(String nv129) {
        this.nv129 = nv129;
    }

    /**
     * @return the nv130
     */
    public String getNv130() {
        return nv130;
    }

    /**
     * @param nv130 the nv130 to set
     */
    public void setNv130(String nv130) {
        this.nv130 = nv130;
    }

    /**
     * @return the listComboK300
     */
    public List<SelectItem> getListComboK300() {
        ComboboxUtil com = new ComboboxUtil();
        listComboK300 = com.getlistCombK300("K");
        return listComboK300;
    }

    /**
     * @param listComboK300 the listComboK300 to set
     */
    public void setListComboK300(List<SelectItem> listComboK300) {
        this.listComboK300 = listComboK300;
    }

    /**
     * @return the listComboK350
     */
    public List<SelectItem> getListComboK330() {
        ComboboxUtil com = new ComboboxUtil();
        listComboK330 = com.getlistCombK330("K");
        return listComboK330;
    }

    /**
     * @param listComboK350 the listComboK350 to set
     */
    public void setListComboK330(List<SelectItem> listComboK330) {
        this.listComboK330 = listComboK330;
    }

    /**
     * @return the FK300
     */
    public int getFK300() {
        return FK300;
    }

    /**
     * @param FK300 the FK300 to set
     */
    public void setFK300(int FK300) {
        this.FK300 = FK300;
    }

    /**
     * @return the FK330
     */
    public int getFK330() {
        return FK330;
    }

    /**
     * @param FK330 the FK330 to set
     */
    public void setFK330(int FK330) {
        this.FK330 = FK330;
    }

    /**
     * @return the Offset
     */
    public int getOffset() {
        return Offset;
    }

    /**
     * @param Offset the Offset to set
     */
    public void setOffset(int Offset) {
        this.Offset = Offset;
    }

    /**
     * @return the Limit
     */
    public int getLimit() {
        return Limit;
    }

    /**
     * @param Limit the Limit to set
     */
    public void setLimit(int Limit) {
        this.Limit = Limit;
    }

    // property for paging
    /**
     * @return the current
     */
    public int getCurrent() {
        if (current > totalpage) {
            current = totalpage;
        } else if (current < 1) {
            current = 1;
        }
        return current;
    }

    /**
     * @param current the current to set
     */
    public void setCurrent(int current) {

        start = (current - 1) * getNumrow();
        end = current * numrow;
        this.current = current;
    }

    /**
     * @return the numrow
     */
    public int getNumrow() {
        if (numrow == 0) {
            numrow = 30;
        }
        return numrow;
    }

    /**
     * @param numrow the numrow to set
     */
    public void setNumrow(int numrow) {
        this.numrow = numrow;
    }

    /**
     * @return the start
     */
    public int getStart() {
        if (start == 0) {
            start = 1;
        }
        return start;
    }

    /**
     * @param start the start to set
     */
    public void setStart(int start) {
        this.start = start;
    }

    /**
     * @return the end
     */
    public int getEnd() {
        if (end == 0) {
            end = 20;
        }
        return end;
    }

    /**
     * @param end the end to set
     */
    public void setEnd(int end) {
        this.end = end;
    }

    /**
     * @return the totalrow
     */
    public int getTotalrow() {
        return totalrow;
    }

    /**
     * @param totalrow the totalrow to set
     */
    public void setTotalrow(int totalrow) {
//        if (totalrow == 0) {
//            totalrow = 100;
//        }
        totalpage = totalrow / numrow;

        if (totalrow % numrow > 0) {
            totalpage = totalpage + 1;
        }


        if (getTotalpage() <= 10) {
            setStartpage(1);
            setEndpage(getTotalpage());

        } else {
            setStartpage(current - 5);
            setEndpage(current + 5);


        }
        this.totalrow = totalrow;
    }

    /**
     * @return the startpage
     */
    public int getStartpage() {
        if (startpage < 1) {
            startpage = 1;
        }
        return startpage;
    }

    /**
     * @param startpage the startpage to set
     */
    public void setStartpage(int startpage) {
        this.startpage = startpage;
    }

    /**
     * @return the endpage
     */
    public int getEndpage() {
        if (endpage > totalpage) {
            endpage = totalpage;
        }
        return endpage;
    }

    /**
     * @param endpage the endpage to set
     */
    public void setEndpage(int endpage) {

        this.endpage = endpage;
    }

    /**
     * @return the totalpage
     */
    public int getTotalpage() {
//        if (totalpage == 0) {
//            totalpage = 10;
//        }
        return totalpage;
    }

    /**
     * @param totalpage the totalpage to set
     */
    public void setTotalpage(int totalpage) {
        this.totalpage = totalpage;
    }

    /**
     * @return the pagename
     */
    public String getPagename() {
        return pagename;
    }

    /**
     * @param pagename the pagename to set
     */
    public void setPagename(String pagename) {
        this.pagename = pagename;
    }

    /**
     * @return the totalcurent
     */
    public int getTotalcurent() {
        return totalcurent;
    }

    /**
     * @param totalcurent the totalcurent to set
     */
    public void setTotalcurent(int totalcurent) {
        this.totalcurent = totalcurent;
    }

    /**
     * @return the typesearchcurent
     */
    public int getTypesearchcurent() {
        return typesearchcurent;
    }

    /**
     * @param typesearchcurent the typesearchcurent to set
     */
    public void setTypesearchcurent(int typesearchcurent) {
        this.typesearchcurent = typesearchcurent;
    }

    /**
     * @return the listSelected
     */
    public List<N100> getListSelected() {
        if (listSelected != null) {
            //  System.out.println("----" + listSelected.size() + "----noi dung --" + listSelected.get(0).getNv958() + "----det-" + listSelected.get(0).getNv961());
        }
        return listSelected;
    }

    /**
     * @param listSelected the listSelected to set
     */
    public void setListSelected(List<N100> listSelected) {
        this.listSelected = listSelected;
    }

    /**
     * @return the mv305
     */
    public String getMv305() {
        return mv305;
    }

    /**
     * @param mv305 the mv305 to set
     */
    public void setMv305(String mv305) {
        this.mv305 = mv305;
    }

    /**
     * @return the mv302
     */
    public String getMv302() {
        return mv302;
    }

    /**
     * @param mv302 the mv302 to set
     */
    public void setMv302(String mv302) {
        this.mv302 = mv302;
    }

    /**
     * @return the md301
     */
    public Date getMd301() {
        return md301;
    }

    /**
     * @param md301 the md301 to set
     */
    public void setMd301(Date md301) {
        this.md301 = md301;
    }

    /**
     * @return the mv303
     */
    public String getMv303() {
        return mv303;
    }

    /**
     * @param mv303 the mv303 to set
     */
    public void setMv303(String mv303) {
        this.mv303 = mv303;
    }

    /**
     * @return the mv304
     */
    public String getMv304() {
        return mv304;
    }

    /**
     * @param mv304 the mv304 to set
     */
    public void setMv304(String mv304) {
        this.mv304 = mv304;
    }

    /**
     * @return the mv306
     */
    public String getMv306() {
        return mv306;
    }

    /**
     * @param mv306 the mv306 to set
     */
    public void setMv306(String mv306) {
        this.mv306 = mv306;
    }

    /**
     * @return the mv307
     */
    public String getMv307() {
        return mv307;
    }

    /**
     * @param mv307 the mv307 to set
     */
    public void setMv307(String mv307) {
        this.mv307 = mv307;
    }

    /**
     * @return the mv308
     */
    public String getMv308() {
        return mv308;
    }

    /**
     * @param mv308 the mv308 to set
     */
    public void setMv308(String mv308) {
        this.mv308 = mv308;
    }

    /**
     * @return the mv309
     */
    public String getMv309() {
        return mv309;
    }

    /**
     * @param mv309 the mv309 to set
     */
    public void setMv309(String mv309) {
        this.mv309 = mv309;
    }

    /**
     * @return the mv310
     */
    public String getMv310() {
        return mv310;
    }

    /**
     * @param mv310 the mv310 to set
     */
    public void setMv310(String mv310) {
        this.mv310 = mv310;
    }

    /**
     * @return the mn314
     */
    public int getMn314() {
        return mn314;
    }

    /**
     * @param mn314 the mn314 to set
     */
    public void setMn314(int mn314) {
        this.mn314 = mn314;
    }

    /**
     * @return the NV115
     */
    public String getNV115() {
        return NV115;
    }

    /**
     * @param NV115 the NV115 to set
     */
    public void setNV115(String NV115) {
        this.NV115 = NV115;
    }

    /**
     * @return the empString
     */
    public String getEmpString() {
        return empString;
    }

    /**
     * @param empString the empString to set
     */
    public void setEmpString(String empString) {
        this.empString = empString;
    }

    public Boolean checkExistList(List<N100> list, int index) {
        for (N100 n100 : list) {
            if (n100.getPn100() == index) {
                return true;
            }
        }
        return false;
    }

    /**
     * @return the KV108
     */
    public String getKV108() {
        return KV108;
    }

    /**
     * @param KV108 the KV108 to set
     */
    public void setKV108(String KV108) {
        this.KV108 = KV108;
    }

    /**
     * @return the NN117
     */
    public int getNN117() {
        return NN117;
    }

    /**
     * @param NN117 the NN117 to set
     */
    public void setNN117(int NN117) {
        this.NN117 = NN117;
    }

    /**
     * @return the choisetab
     */
    public int getChoisetab() {
        return choisetab;
    }

    /**
     * @param choisetab the choisetab to set
     */
    public void setChoisetab(int choisetab) {
        this.choisetab = choisetab;
    }

    /**
     * @return the dayss
     */
    public int getDayss() {
        return dayss;
    }

    /**
     * @param dayss the dayss to set
     */
    public void setDayss(int dayss) {
        this.dayss = dayss;
    }

    /**
     * @return the lstEmpByID
     */
    public List<SelectItem> getLstEmpByIDConvert() {
        String emp = loginEmp;
        try {
            if (lstEmpByID == null || lstEmpByID.size() < 1) {
                lstEmpByID = com.getSelectedN900CombConvert(0);

            }

        } catch (Exception e) {
            System.out.println("getLstEmpByID error--:" + e.getMessage());
            lstEmpByID = new ArrayList<SelectItem>();
        }

        System.out.println("getLstEmpByID-size-" + lstEmpByID.size() + "---fn850--" + fn850 + "--emplogin--" + loginEmp + "--userAction--" + userAction);
        return lstEmpByID;
    }

    public List<SelectItem> getLstEmpByID() {
        String emp = loginEmp;
        try {
            if (lstEmpByID == null || lstEmpByID.size() < 1) {
                lstEmpByID = com.getSelectedN900Comb(fn850);
                for (int i = 0; i < lstEmpByID.size(); i++) {
                    if (lstEmpByID.get(i).getValue().toString().equals(loginEmp)) {
                        //neu nhan vien dc chon co trong nhom to
                        emp = lstEmpByID.get(i).getValue().toString();
                        break;
                    } else {//neu ko co thi gan la ng dau tien
                        emp = lstEmpByID.get(0).getValue().toString();
                    }
                }
                loginEmp = emp;
                if (flagFN850 == 10) {
                    userAction = emp;
                }
                SessionProvider.setSessionMapValue("emp", loginEmp);
            }

        } catch (Exception e) {
            System.out.println("getLstEmpByID error--:" + e.getMessage());
            lstEmpByID = new ArrayList<SelectItem>();
        }

        System.out.println("getLstEmpByID-size-" + lstEmpByID.size() + "---fn850--" + fn850 + "--emplogin--" + loginEmp + "--userAction--" + userAction);
        return lstEmpByID;
    }

    /**
     * @param lstEmpByID the lstEmpByID to set
     */
    public void setLstEmpByID(List<SelectItem> lstEmpByID) {
        this.lstEmpByID = lstEmpByID;
    }

    /**
     * @return the fn850
     */
    public int getFn850() {
        return fn850;
    }

    /**
     * @param fn850 the fn850 to set
     */
    public void setFn850(int fn850) {
        this.fn850 = fn850;
    }

    /**
     * @return the loginEmp
     */
    public String getLoginEmp() {
        if(SessionProvider.getSessionMapValue("emp")!=null){
            loginEmp = SessionProvider.getSessionMapValue("emp").toString(); 
        }else{
            if(getLogin().getUserName()!=null){
            loginEmp = getLogin().getUserName();
           
        }
        }
        
        return loginEmp;
    }

    /**
     * @param loginEmp the loginEmp to set
     */
    public void setLoginEmp(String loginEmp) {
        this.loginEmp = loginEmp;
    }

    /**
     * @return the IDsavedouble
     */
    public int getIDsavedouble() {
        return IDsavedouble;
    }

    /**
     * @param IDsavedouble the IDsavedouble to set
     */
    public void setIDsavedouble(int IDsavedouble) {
        this.IDsavedouble = IDsavedouble;
    }

    /**
     * @return the listK100TT
     */
    public List<K100> getListK100TT() {
        Object o = SessionProvider.getSessionMapValue("typeSearchEx");
        if (o != null) {
            int type;
            try {
                type = Integer.parseInt(o.toString());
            } catch (Exception e) {
                type = 0;
            }
            setTypesearch(type);

        }
        if (getTypesearch() == 1) {
            K100Store k100Store = new K100Store();
            listK100TT = k100Store.getListCompany_NA(getLogin().getModule(), getLogin().getCompanyNo(), getKeySearch(), Offset, Limit, 0, 0, getLogin().getUserName());
            System.out.println("-------------------KEY---" + keySearch + listK100TT.size());


        }
        return listK100TT;
    }

    /**
     * @param listK100TT the listK100TT to set
     */
    public void setListK100TT(List<K100> listK100TT) {
        this.listK100TT = listK100TT;
    }

    /**
     * @return the nv123
     */
    public String getNv123() {
        return nv123;
    }

    /**
     * @param nv123 the nv123 to set
     */
    public void setNv123(String nv123) {
        this.nv123 = nv123;
    }

    /**
     * @return the ND131
     */
    public Date getND131() {
        return ND131;
    }

    /**
     * @param ND131 the ND131 to set
     */
    public void setND131(Date ND131) {
        this.ND131 = ND131;
    }

    /**
     * @return the KD115
     */
    public Date getKD115() {
        return KD115;
    }

    /**
     * @param KD115 the KD115 to set
     */
    public void setKD115(Date KD115) {
        this.KD115 = KD115;
    }

    /**
     * @return the endDateSta
     */
    public Date getEndDateSta() {
        return endDateSta;
    }

    /**
     * @param endDateSta the endDateSta to set
     */
    public void setEndDateSta(Date endDateSta) {
        this.endDateSta = endDateSta;
    }

    /**
     * @return the dateStatus
     */
    public Date getDateStatus() {
        return dateStatus;
    }

    /**
     * @param dateStatus the dateStatus to set
     */
    public void setDateStatus(Date dateStatus) {
        this.dateStatus = dateStatus;
    }

    /**
     * @return the dayID
     */
    public int getDayID() {
        return dayID;
    }

    /**
     * @param dayID the dayID to set
     */
    public void setDayID(int dayID) {
        this.dayID = dayID;
    }

    /**
     * @return the checkSMS
     */
    public int getCheckSMS() {
        return checkSMS;
    }

    /**
     * @param checkSMS the checkSMS to set
     */
    public void setCheckSMS(int checkSMS) {
        this.checkSMS = checkSMS;
    }

    /**
     * @return the rowdemo
     */
    public int getRowdemo() {
        return rowdemo;
    }

    /**
     * @param rowdemo the rowdemo to set
     */
    public void setRowdemo(int rowdemo) {
        this.rowdemo = rowdemo;
    }
}
